package com.simon.hse.http;

import android.util.Log;

import com.simon.hse.MyApplication;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;

/**
 * 创建读取Cookie的拦截器
 */
@SuppressWarnings("all")
public class ReadCookiesInterceptor implements Interceptor {

    @Override
    public okhttp3.Response intercept(Chain chain) throws IOException {
        Request.Builder builder = chain.request().newBuilder();
        String cookie = PreferencesCookie.getString(MyApplication.getInstance(), "cookie", "");
        //将cookie添加到请求头中
        // Log.i("Simon", "HowToUseReadMe Cookie = " + cookie);
        builder.addHeader("Cookie", cookie);
        return chain.proceed(builder.build());
    }
}